﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Windows.Design.Metadata;
using Microsoft.Windows.Design.PropertyEditing;

namespace DenisVuyka.Controls.PropertyGrid.Metadata
{
  public sealed class DefaultMetadataBuilder : AttributeTableBuilder
  {
    public DefaultMetadataBuilder()
    {
      base.AddCallback(typeof(FontStretch), (builder) =>
       builder.AddCustomAttributes(new Attribute[] { new TypeConverterAttribute(typeof(FontStretchConverterDecorator)) }));

      base.AddCallback(typeof(FontStyle), (builder) =>
        builder.AddCustomAttributes(new Attribute[] { new TypeConverterAttribute(typeof(FontStyleConverterDecorator)) }));

      base.AddCallback(typeof(FontWeight), (builder) =>
        builder.AddCustomAttributes(new Attribute[] { new TypeConverterAttribute(typeof(FontWeightConverterDecorator)) }));

      base.AddCallback(typeof(Button), (builder) =>
          builder.AddCustomAttributes(Control.OpacityProperty,
            new NumberRangeAttribute(0, 1, 0.1, 1),
            PropertyValueEditor.CreateEditorAttribute(typeof(ValueEditors.SliderPropertyValueEditor))));
    }
  }
}
